<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>
<?=$page_title?>
</title>
<base href="<?=base_url()?>" />
<script type="text/javascript" src="js/jquery.js"></script>
<!--time-->
<link rel="stylesheet" href="themes/base/jquery.ui.all.css">
<script src="js/ui/jquery.ui.core.js"></script>
<script src="js/ui/jquery.ui.widget.js"></script>
<script src="js/ui/jquery.ui.datepicker.js"></script>
<link rel="stylesheet" href="css/demos.css">
<!--弹窗-->
<link href="css/clientpublic.css" rel="stylesheet" type="text/css">
<link href="css/esui.css" rel="stylesheet" type="text/css">
<link href="css/initaccount.css" rel="stylesheet" type="text/css">
<link href="css/guo.css" rel="stylesheet" type="text/css">

<script type="text/javascript" src="js/fancybox/jquery.fancybox-1.3.4.pack.js"></script>
<script type="text/javascript" src="js/fancybox/jquery.easing-1.3.pack.js"></script>
<script type="text/javascript" src="js/fancybox/jquery.mousewheel-3.0.4.pack.js"></script>
<link rel="stylesheet" type="text/css" href="js/fancybox/jquery.fancybox-1.3.4.css" />
<link rel="stylesheet" type="text/css" href="css/jia.css" />
<script language='javascript' src='js/suggest.js'></script>
<link href="js/suggest.css" rel="stylesheet" type="text/css">
<script type="text/javascript">
	$(document).ready(function() {
		jQuery.ajaxSetup ({cache:false}); /*让ajax不调用浏览的缓存*/
		$(".various1").fancybox({
		'titleShow'     : false,
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'elastic',
		'easingIn'      : 'easeOutBack',
		'easingOut'     : 'easeInBack',
		'hideOnOverlayClick' : false,
		'onComplete'	: function() {
				var suggest = new GoogleSuggest("myform", "customer_name", 0,'');
			}
		});

		$("#payment_plan").click(function(){
            var subject=$.trim($("#payment_plan_name").val());
            if(subject == ""){
              alert("请输入名称后查询");
            }else{
				location.href="<?=base_url()?>index.php/payment_plan/check/"+subject+"";
              }
		})

		$("#check_info").change(function(){
			var user_id = $("#check_info").val();
			location.href="<?= base_url()?>index.php/payment_plan/check_user_messages/"+user_id+"";
		})
	});
</script>
</head>
<body>
	<div id="Holder">
		<div id="MainPage">
			<!--头部-->
			<?php include('top.php')?>
			<div id="Subnav">
				<ul>
					<li class="active show"></li>
				</ul>
			</div>
			<!--合同列表-->
            <div class="Subnav_cont">
                <!--回款计划-->
                <div id="MainBody">
                    <div class="g_title">
                        <div class="g_earch">
                              <input type="text" class="g_title_text"
                                value="回款计划" onClick="this.value=''" id="payment_plan_name"/>
                                <input type="button" id="payment_plan" value=" " class="g_title_sub"></input>
                        </div>
                        
                        <div class="g_select">
                       <?php 
                       		$user_name = $this->session->userdata('username');
                       		$role = $this->session->userdata('role');
                       		?>
                       		<?php if($role == '经理' || $role == '商务助理'):?>
                    	<select id="check_info">
                    	<option value="0" <?php if($check_user_name == ''):?> selected='selected' <?php endif;?>>请选择所有者</option>
                    	<?php foreach ($all_users as $user):?>
                    	    	<?php if($user->user_name != '何俊斌'):?>
                    			<option value="<?= $user->id?>" <?php if($user->user_name == $check_user_name):?> selected='selected' <?php endif;?>><?= $user->user_name?></option>
                    		<?php endif;?>
                        <?php endforeach;?>
                        </select>
                        <?php endif;?>
                    </div>
                        
                        <div class="add_customer">
                            <div class="add_customer_bg7"><?=anchor('payment_plan/show_Payment_record_add/',' ','class="various1"','id="find"') ?></div>
                        </div>
                    </div>
                    <table id="ContentTable" class="data-box">
                        <thead>
                            <tr class="border-in">
                                <th><div>ID</div></th>
                                <th><div>金额</div></th>
                                <th><div>计划回款日期</div></th>
                                <th><div>合同/订单</div></th>
                                <th><div>客户</div></th>
                                <th><div>期次</div></th>
                                <th><div>是否回款</div></th>
                                <th><div>所有者</div></th>
                                <th><div>操作</div></th>
                            </tr>
                        </thead>
                        <tbody>
                        <?php foreach ($payment_plans as $payment_plan): ?>
                        <tr class="data-box-row">
                                <td><?= $payment_plan->id ?></td>
                                <td><?= $payment_plan->money ?></td>
								<?php 
								if($payment_plan->payment_time == null || $payment_plan->payment_time == '' || $payment_plan->payment_time == '0000-00-00 00:00:00'){
									$paymenttime = '';
								}else{
									$datatime = strtotime($payment_plan->payment_time);
									$paymenttime = date( "Y-m-d",$datatime);
								}
								?>
                                <td><?=  $paymenttime?></td>
                                <td><?= $payment_plan->contract_subject ?></td>
                                <td><?= $payment_plan->customer_name ?></td>
                                <td><?= $payment_plan->stages ?></td>
                                <?php
                                $back='未回';
                                $color='red';
                                if($payment_plan->back==1){
                                	$back='已回';
                                	$color='green';
                                }?>
                                <td style="color:<?php echo $color;?>;"><?= $back ?></td>
                                <td><?= $payment_plan->user_name ?></td>
                                <td><a href="<?=base_url()?>index.php/payment_plan/find/<?= $payment_plan->id ?>"
                                    class="various1 g_see" id="find" title="">查看</a>&nbsp;&nbsp; <a
                                    href="<?=base_url()?>index.php/payment_plan/edit/<?= $payment_plan->id ?>"
                                    class="various1 g_edit" id="find" title="">编辑</a>&nbsp;&nbsp; <span class="g_dele"
                                    id="delete<?= $payment_plan->id ?>">删除</span> <input
                                    type="hidden" id="payment_plan_id<?= $payment_plan->id ?>"
                                    value="<?= $payment_plan->id ?>" /> <script
                                        type="text/javascript">
                                         $(function(){
                                             $("#delete<?= $payment_plan->id ?>").click(function(){
                                                if (window.confirm("您确定要删除吗？")) {
                                                    var id=$("#payment_plan_id<?=$payment_plan->id ?>").val();
                                                    location.href="<?=base_url()?>index.php/payment_plan/delete/"+id+"";
                                                } else {
                                                }
                                            })
                                         })
                                    </script></td>
                            </tr>
                      <?php endforeach; ?>
                    </tbody>
                    </table>
                    <div id="PageControl">
                        <div class="page-control">
                            <div class="border-in">
                                <span class="perpage"> <span class="perpage-text">
                                <?php if($pag_links){?>
                                    <?echo ($offset) ? ($offset+1):1;?> - <?=$current_total?> 条（共<?=$total?>条）
                                <?php }?>
                                </span>
                                </span>
                                <p>
                                    <?php if($pag_links){
                                        echo $pag_links;
                                    }?>
                                </p>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
			<!--结尾-->
			<?php include('footer.php')?>
		</div>
	</div>
    <script type="text/javascript">
    	$(document).ready(function(){
			$(".level_two ul li").click(function(){
				$(".level_two ul li").removeClass("active");
				$(this).addClass("active");
				$(".Subnav_cont #MainBody").hide();
				var i=$(".level_two ul li").index(this)
				$(".Subnav_cont #MainBody").eq(i).show();

			});
		});
    </script>
    <input type="hidden" id="baseurl" value="<?=base_url()?>"/>
</body>
</html>